clear all
use "Data\W5 (Finaldata Post-Imputation).dta"

gen u=runiform()
sort u

psmatch2 treatment gender age education residence employment family_status household_income Election_Participation Internet_Use, outcome (Democratic_Suitability) logit neighbor(1) common caliper(.05) ties ate
pstest ,both graph 

psmatch2 treatment gender age education residence employment family_status household_income Election_Participation Internet_Use, outcome (Democratic_Preferability) logit neighbor(1) common caliper(.05) ties ate
pstest ,both graph

psmatch2 treatment gender age education residence employment family_status household_income Election_Participation Internet_Use, outcome (Democratic_Priority) logit neighbor(1) common caliper(.05) ties ate
pstest ,both graph

psmatch2 treatment gender age education residence employment family_status household_income Election_Participation Internet_Use, outcome (Democratic_Necessity) logit neighbor(1) common caliper(.05) ties ate
pstest ,both graph

*****Output Fig. A5 The Results of Balance Diagnostics Before and After PSMs*****
graph export "Results/Figures/Fig. A5 The Results of Balance Diagnostics Before and After PSMs.png", replace
******Although we did the pstest four times, the results were exactly the same all four times, and this is because the pstest does not vary with Outcome varieble, so we took the results of the last test as the standard******


****Since the psmatch2 command cannot output the result we want directly, we manually construct file tableA4 by putdocx according to the output result in Results Window of stata.*****
putdocx begin
putdocx paragraph, style(Heading1)
putdocx paragraph, font("Times New Roman", 12, black)
putdocx text ("Table A4 The Results of Balance Diagnostics Before and After PSM") 
putdocx table mytable = (19, 9)

putdocx table mytable(1, 1) = ("Variable"), font("Times New Roman")  
putdocx table mytable(1, 2) = ("Unmatched/"Matched""), font("Times New Roman")  
putdocx table mytable(1, 3) = ("Mean of Treated"), font("Times New Roman")   
putdocx table mytable(1, 4) = ("Mean of Control"), font("Times New Roman")  
putdocx table mytable(1, 5) = ("%bias"), font("Times New Roman")  
putdocx table mytable(1, 6) = ("%redut"), font("Times New Roman")  
putdocx table mytable(1, 7) = ("t"), font("Times New Roman")  
putdocx table mytable(1, 8) = ("p>|t|"), font("Times New Roman")  
putdocx table mytable(1, 9) = ("V(T)/V(C)"), font("Times New Roman")  

putdocx table mytable(2, 1) = ("gender"), font("Times New Roman")  
putdocx table mytable(2, 2) = ("U"), font("Times New Roman")  
putdocx table mytable(2, 3) = (1.5337), font("Times New Roman")  
putdocx table mytable(2, 4) = (1.5255), font("Times New Roman")  
putdocx table mytable(2, 5) = (1.6), font("Times New Roman")  
putdocx table mytable(2, 6) = (""), font("Times New Roman")  
putdocx table mytable(2, 7) = (0.89), font("Times New Roman")  
putdocx table mytable(2, 8) = (0.371), font("Times New Roman")  
putdocx table mytable(2, 9) = (1.00), font("Times New Roman")  

putdocx table mytable(3, 1) = ("gender"), font("Times New Roman")  
putdocx table mytable(3, 2) = ("M"), font("Times New Roman")    
putdocx table mytable(3, 3) = (1.5336), font("Times New Roman")  
putdocx table mytable(3, 4) = (1.546), font("Times New Roman")  
putdocx table mytable(3, 5) = (-2.5), font("Times New Roman")  
putdocx table mytable(3, 6) = (-50.4), font("Times New Roman")  
putdocx table mytable(3, 7) = (-1.43), font("Times New Roman")  
putdocx table mytable(3, 8) = (0.153), font("Times New Roman")  
putdocx table mytable(3, 9) = (1.00), font("Times New Roman")  

putdocx table mytable(4, 1) = ("age"), font("Times New Roman")  
putdocx table mytable(4, 2) = ("U"), font("Times New Roman")  
putdocx table mytable(4, 3) = (49.837), font("Times New Roman")  
putdocx table mytable(4, 4) = (46.054), font("Times New Roman")  
putdocx table mytable(4, 5) = (22.2), font("Times New Roman")  
putdocx table mytable(4, 6) = (""), font("Times New Roman")   
putdocx table mytable(4, 7) = (12.02), font("Times New Roman")  
putdocx table mytable(4, 8) = (0.000), font("Times New Roman")  
putdocx table mytable(4, 9) = ("1.06*"), font("Times New Roman")  

putdocx table mytable(5, 1) = ("age"), font("Times New Roman")  
putdocx table mytable(5, 2) = ("M"), font("Times New Roman")  
putdocx table mytable(5, 3) = (49.832), font("Times New Roman")  
putdocx table mytable(5, 4) = (50.214), font("Times New Roman")  
putdocx table mytable(5, 5) = (-2.2), font("Times New Roman")  
putdocx table mytable(5, 6) = (89.9), font("Times New Roman")  
putdocx table mytable(5, 7) = (-1.27), font("Times New Roman")  
putdocx table mytable(5, 8) = (0.203), font("Times New Roman")  
putdocx table mytable(5, 9) = (1.00), font("Times New Roman")  

putdocx table mytable(6, 1) = ("education"), font("Times New Roman")  
putdocx table mytable(6, 2) = ("U"), font("Times New Roman")  
putdocx table mytable(6, 3) = (4.3183), font("Times New Roman")  
putdocx table mytable(6, 4) = (5.4142), font("Times New Roman")  
putdocx table mytable(6, 5) = (-63.9), font("Times New Roman")  
putdocx table mytable(6, 6) = (""), font("Times New Roman")   
putdocx table mytable(6, 7) = (-34.66), font("Times New Roman")  
putdocx table mytable(6, 8) = (0.000), font("Times New Roman")  
putdocx table mytable(6, 9) = (0.99), font("Times New Roman")  

putdocx table mytable(7, 1) = ("education"), font("Times New Roman")  
putdocx table mytable(7, 2) = ("M"), font("Times New Roman")   
putdocx table mytable(7, 3) = (4.3164), font("Times New Roman")  
putdocx table mytable(7, 4) = (4.3283), font("Times New Roman")  
putdocx table mytable(7, 5) = (-0.7), font("Times New Roman")   
putdocx table mytable(7, 6) = (98.9), font("Times New Roman")  
putdocx table mytable(7, 7) = (-0.40), font("Times New Roman")  
putdocx table mytable(7, 8) = (0.686), font("Times New Roman")  
putdocx table mytable(7, 9) = (1.02), font("Times New Roman")  

putdocx table mytable(8, 1) = ("residence"), font("Times New Roman")  
putdocx table mytable(8, 2) = ("U"), font("Times New Roman")   
putdocx table mytable(8, 3) = (1.4305), font("Times New Roman")  
putdocx table mytable(8, 4) = (1.6378), font("Times New Roman")  
putdocx table mytable(8, 5) = (-42.5), font("Times New Roman")   
putdocx table mytable(8, 6) = (""), font("Times New Roman")  
putdocx table mytable(8, 7) = (-23.00), font("Times New Roman")  
putdocx table mytable(8, 8) = (0.000), font("Times New Roman")  
putdocx table mytable(8, 9) = ("1.06*"), font("Times New Roman")  

putdocx table mytable(9, 1) = ("residence"), font("Times New Roman")  
putdocx table mytable(9, 2) = ("M"), font("Times New Roman")   
putdocx table mytable(9, 3) = (1.4303), font("Times New Roman")  
putdocx table mytable(9, 4) = (1.4276), font("Times New Roman")  
putdocx table mytable(9, 5) = (0.6), font("Times New Roman")  
putdocx table mytable(9, 6) = (98.7), font("Times New Roman")   
putdocx table mytable(9, 7) = (0.32), font("Times New Roman")  
putdocx table mytable(9, 8) = (0.752), font("Times New Roman")  
putdocx table mytable(9, 9) = (1.00), font("Times New Roman")  

putdocx table mytable(10, 1) = ("employment"), font("Times New Roman")  
putdocx table mytable(10, 2) = ("U"), font("Times New Roman")   
putdocx table mytable(10, 3) = (1.3571), font("Times New Roman")  
putdocx table mytable(10, 4) = (1.3082), font("Times New Roman")  
putdocx table mytable(10, 5) = (10.4), font("Times New Roman")  
putdocx table mytable(10, 6) = (""), font("Times New Roman")    
putdocx table mytable(10, 7) = (5.62), font("Times New Roman")  
putdocx table mytable(10, 8) = (0.000), font("Times New Roman")  
putdocx table mytable(10, 9) = ("1.08*"), font("Times New Roman")  

putdocx table mytable(11, 1) = ("employment"), font("Times New Roman")  
putdocx table mytable(11, 2) = ("M"), font("Times New Roman")  
putdocx table mytable(11, 3) = (1.3569), font("Times New Roman")  
putdocx table mytable(11, 4) = (1.3435), font("Times New Roman")  
putdocx table mytable(11, 5) = (2.9), font("Times New Roman")  
putdocx table mytable(11, 6) = (72.5), font("Times New Roman")   
putdocx table mytable(11, 7) = (1.62), font("Times New Roman")  
putdocx table mytable(11, 8) = (0.105), font("Times New Roman")  
putdocx table mytable(11, 9) = (1.02), font("Times New Roman")  

putdocx table mytable(12, 1) = ("family_status"), font("Times New Roman")  
putdocx table mytable(12, 2) = ("U"), font("Times New Roman")   
putdocx table mytable(12, 3) = (4.9656), font("Times New Roman")  
putdocx table mytable(12, 4) = (4.883), font("Times New Roman")  
putdocx table mytable(12, 5) = (6.7), font("Times New Roman")  
putdocx table mytable(12, 6) = (""), font("Times New Roman")    
putdocx table mytable(12, 7) = (3.60), font("Times New Roman")  
putdocx table mytable(12, 8) = (0.001), font("Times New Roman")  
putdocx table mytable(12, 9) = (1.26), font("Times New Roman")  

putdocx table mytable(13, 1) = ("family_status"), font("Times New Roman")  
putdocx table mytable(13, 2) = ("M"), font("Times New Roman")   
putdocx table mytable(13, 3) = (4.9662), font("Times New Roman")  
putdocx table mytable(13, 4) = (4.9511), font("Times New Roman")  
putdocx table mytable(13, 5) = (1.2), font("Times New Roman")    
putdocx table mytable(13, 6) = (81.7), font("Times New Roman")  
putdocx table mytable(13, 7) = (0.68), font("Times New Roman")  
putdocx table mytable(13, 8) = (0.494), font("Times New Roman")  
putdocx table mytable(13, 9) = ("1.10*"), font("Times New Roman")  

putdocx table mytable(14, 1) = ("household_income"), font("Times New Roman")  
putdocx table mytable(14, 2) = ("U"), font("Times New Roman")    
putdocx table mytable(14, 3) = (2.5236), font("Times New Roman")  
putdocx table mytable(14, 4) = (2.8783), font("Times New Roman")  
putdocx table mytable(14, 5) = (-30.1), font("Times New Roman")  
putdocx table mytable(14, 6) = (""), font("Times New Roman")   
putdocx table mytable(14, 7) = (-16.32), font("Times New Roman")  
putdocx table mytable(14, 8) = (0.000), font("Times New Roman")  
putdocx table mytable(14, 9) = (1.01), font("Times New Roman")  

putdocx table mytable(15, 1) = ("household_income"), font("Times New Roman")  
putdocx table mytable(15, 2) = ("M"), font("Times New Roman")    
putdocx table mytable(15, 3) = (2.5238), font("Times New Roman")  
putdocx table mytable(15, 4) = (2.4977), font("Times New Roman")  
putdocx table mytable(15, 5) = (2.2), font("Times New Roman")  
putdocx table mytable(15, 6) = (92.6), font("Times New Roman")   
putdocx table mytable(15, 7) = (1.31), font("Times New Roman")  
putdocx table mytable(15, 8) = (0.189), font("Times New Roman")  
putdocx table mytable(15, 9) = ("1.14*"), font("Times New Roman")  

putdocx table mytable(16, 1) = ("Election_Participation"), font("Times New Roman")  
putdocx table mytable(16, 2) = ("U"), font("Times New Roman")  
putdocx table mytable(16, 3) = (1.2153), font("Times New Roman")  
putdocx table mytable(16, 4) = (1.2438), font("Times New Roman")  
putdocx table mytable(16, 5) = (-6.6), font("Times New Roman")   
putdocx table mytable(16, 6) = (""), font("Times New Roman")  
putdocx table mytable(16, 7) = (-3.60), font("Times New Roman")  
putdocx table mytable(16, 8) = (0.000), font("Times New Roman")  
putdocx table mytable(16, 9) = ("0.86*"), font("Times New Roman")  

putdocx table mytable(17, 1) = ("Election_Participation"), font("Times New Roman")  
putdocx table mytable(17, 2) = ("M"), font("Times New Roman")   
putdocx table mytable(17, 3) = (1.2154), font("Times New Roman")  
putdocx table mytable(17, 4) = (1.2018), font("Times New Roman")  
putdocx table mytable(17, 5) = (3.2), font("Times New Roman")   
putdocx table mytable(17, 6) = (52.2), font("Times New Roman")  
putdocx table mytable(17, 7) = (1.90), font("Times New Roman")  
putdocx table mytable(17, 8) = (0.057), font("Times New Roman")  
putdocx table mytable(17, 9) = (1.03), font("Times New Roman")  

putdocx table mytable(18, 1) = ("Internet_Use"), font("Times New Roman")  
putdocx table mytable(18, 2) = ("U"), font("Times New Roman")  
putdocx table mytable(18, 3) = (2.1353), font("Times New Roman")  
putdocx table mytable(18, 4) = (2.0622), font("Times New Roman")  
putdocx table mytable(18, 5) = (7.5), font("Times New Roman")   
putdocx table mytable(18, 6) = (""), font("Times New Roman")  
putdocx table mytable(18, 7) = (4.10), font("Times New Roman")  
putdocx table mytable(18, 8) = (0.000), font("Times New Roman")  
putdocx table mytable(18, 9) = ("0.82*"), font("Times New Roman")  

putdocx table mytable(19, 1) = ("Internet_Use"), font("Times New Roman")  
putdocx table mytable(19, 2) = ("M"), font("Times New Roman")   
putdocx table mytable(19, 3) = (2.1353), font("Times New Roman")  
putdocx table mytable(19, 4) = (2.1187), font("Times New Roman")  
putdocx table mytable(19, 5) = (1.7), font("Times New Roman")  
putdocx table mytable(19, 6) = (77.3), font("Times New Roman")  
putdocx table mytable(19, 7) = (1.01), font("Times New Roman")  
putdocx table mytable(19, 8) = (0.313), font("Times New Roman")  
putdocx table mytable(19, 9) = (0.90), font("Times New Roman")  

putdocx save "Results/Tables/Table A4 The Results of Balance Diagnostics Before and After PSM", replace 


*****Table A5 OLS Regression Results of Confucian Values and Democratic Support After PSM*****
reg Democratic_Suitability Family_Values Social_Values Political_Values Country_Economic_Evaluation Family_Economic_Evaluation Social_Capital Political_Interest Political_Efficiency Election_Participation Internet_Use gender age education residence employment family_status household_income i.country i.Year if !missing(_weight), robust
est store m1

reg Democratic_Suitability Family_Values Social_Values Political_Values Country_Economic_Evaluation Family_Economic_Evaluation Social_Capital Political_Interest Political_Efficiency Election_Participation Internet_Use gender age education residence employment family_status household_income i.country i.Year if _support ==1, robust
est store m2


reg Democratic_Preferability Family_Values Social_Values Political_Values Country_Economic_Evaluation Family_Economic_Evaluation Social_Capital Political_Interest Political_Efficiency Election_Participation Internet_Use gender age education residence employment family_status household_income i.country i.Year if !missing(_weight), robust
est store m3

reg Democratic_Preferability Family_Values Social_Values Political_Values Country_Economic_Evaluation Family_Economic_Evaluation Social_Capital Political_Interest Political_Efficiency Election_Participation Internet_Use gender age education residence employment family_status household_income i.country i.Year if _support ==1, robus
est store m4

reg Democratic_Priority Family_Values Social_Values Political_Values Country_Economic_Evaluation Family_Economic_Evaluation Social_Capital Political_Interest Political_Efficiency Election_Participation Internet_Use gender age education residence employment family_status household_income i.country i.Year if !missing(_weight), robust
est store m5

reg Democratic_Priority Family_Values Social_Values Political_Values Country_Economic_Evaluation Family_Economic_Evaluation Social_Capital Political_Interest Political_Efficiency Election_Participation Internet_Use gender age education residence employment family_status household_income i.country i.Year if _support ==1, robust
est store m6


reg Democratic_Necessity Family_Values Social_Values Political_Values Country_Economic_Evaluation Family_Economic_Evaluation Social_Capital Political_Interest Political_Efficiency Election_Participation Internet_Use gender age education residence employment family_status household_income i.country i.Year if !missing(_weight), robust
est store m7


reg Democratic_Necessity Family_Values Social_Values Political_Values Country_Economic_Evaluation Family_Economic_Evaluation Social_Capital Political_Interest Political_Efficiency Election_Participation Internet_Use gender age education residence employment family_status household_income i.country i.Year  if _support ==1, robust
est store m8

esttab m1 m2 m3 m4 m5 m6 m7 m8 using "Results/tables/Table A5 OLS Regression Results of Confucian Values and Democratic Support After PSM.rtf", se mtitle(PSM_Model1 PSM_Model2 PSM_Model3 PSM_Model4 PSM_Model5 PSM_Model6 PSM_Model7 PSM_Model8) keep(Family_Values Social_Values Political_Values _cons) replace b(%12.3f) t(%12.2f) scalars (country Year N r2_a) star(* 0.1 ** 0.05 *** 0.01) nogap compress nonotes note("Note: Robust standard errors in parentheses. *p < 0.1, **p < 0.05, ***p < 0.01. The matching method is PSM, with a 1:1 caliper nearest neighbor matching method (caliper=0.05). Before PSM, the treatment group and control group should be distinguished to generate a binary variable - treatment. We constructed the overall Confucian Values index by averaging an individual's scores on all questions assessing Confucian values. Subsequently, we computed the mean value of this index within our sample, and individuals above this mean were assigned to the treatment group (treatment=1), while those below were allocated to the control group (treatment=0). Model 1, Model 3, Model 5, and Model 7 use samples which is Weight≠Null. Model 2, Model 4, Model 6, and Model 8 use samples which is Common Support=1. Democratic Suitability and Democratic Preferability represent the minimum support for democracy (MSFD). Democratic Priority and Democratic Necessity represent the priority support for democracy (PSFD).") 


*****Table A6 OLS Regression Results of Confucian Values and Democratic Support After EBM*****
clear all
use "Data\W5 (Finaldata Post-Imputation).dta"
ebalance treatment gender age education residence employment family_status household_income Election_Participation Internet_Use, targets(3) 

svyset [pweight=_webal]

svy: reg Democratic_Suitability Family_Values Social_Values Political_Values Country_Economic_Evaluation Family_Economic_Evaluation Social_Capital Political_Interest Political_Efficiency Election_Participation Internet_Use gender age education residence employment family_status household_income i.country i.Year

est store m1

svy: reg Democratic_Preferability Family_Values Social_Values Political_Values Country_Economic_Evaluation Family_Economic_Evaluation Social_Capital Political_Interest Political_Efficiency Election_Participation Internet_Use gender age education residence employment family_status household_income i.country i.Year

est store m2

svy: reg Democratic_Priority Family_Values Social_Values Political_Values Country_Economic_Evaluation Family_Economic_Evaluation Social_Capital Political_Interest Political_Efficiency Election_Participation Internet_Use gender age education residence employment family_status household_income i.country i.Year

est store m3

svy: reg Democratic_Necessity Family_Values Social_Values Political_Values Country_Economic_Evaluation Family_Economic_Evaluation Social_Capital Political_Interest Political_Efficiency Election_Participation Internet_Use gender age education residence employment family_status household_income i.country i.Year

est store m4

esttab m1 m2 m3 m4 using "Results/tables/Table A6 OLS Regression Results of Confucian Values and Democratic Support After EBM.rtf" , se mtitle(EBM_Model_1 EBM_Model_2 EBM_Model_3 EBM_Model_4) keep(Family_Values Social_Values Political_Values _cons) replace b(%12.3f) t(%12.2f) scalars (country Year N r2) star(* 0.1 ** 0.05 *** 0.01) nogap compress nonotes note("Note: Standard errors are in parentheses. *p < 0.1, **p < 0.05, ***p < 0.01. Democratic Suitability and Democratic Preferability represent the minimum support for democracy (MSFD). Democratic Priority and Democratic Necessity represent the priority support for democracy (PSFD).")


